<?php
	$id      = intval($_GET['id']);

$sql = "SELECT 
      updates.u_id AS u_id,
      updates.date_submitted AS date_submitted,
      updates.deadline AS deadline,
      updates.description AS description,
      updates.priority AS priority,
      pages.page_name AS page_name,
      clients.fname AS fname,
      clients.lname AS lname,
      projects.p_url AS p_url,
      projects.p_id AS p_id,
      projects.p_title AS p_title
      FROM updates
      INNER JOIN projects ON updates.p_id = projects.p_id
      INNER JOIN clients  ON projects.c_id  = clients.c_id
	  INNER JOIN pages    ON updates.page  = pages.page_id
      LEFT JOIN admin ON updates.a_id = admin.a_id
      WHERE u_id='$id' LIMIT 1";
	$result  = mysql_query($sql) or die(mysql_error());
	$row     = mysql_fetch_assoc($result);

	// put update_id in hidden form and pass it to the next page
	$u_id = $row['u_id'];
	$p_id = $row['p_id'];
?>
<h4>Viewing update for <i><? echo $row['fname'] ." ". $row['lname']  ?></i> for their <i><a href="<? echo $row['p_url']; ?>" title="View <? echo $row['p_title']; ?>"><? echo $row['p_title']; ?></a> project</i></h4><br />
<h4><b>Posted on: </b> <? echo $row['date_submitted'] = date("F j, Y, g:i a"); ?></h4>

<p>
	<b>Update Due Date:</b> <? echo $row['deadline']; ?><br />
	<b>Page:</b> <? echo $row['page_name']; ?><br />
	<b>Priority:</b> <? echo $row['priority']; ?><br />
	<b>Update Description:</b><br />
	<span><? echo $row['description']; ?></span><br />
	<?php
	if($row['priority'] == "High"){
		print'
		<div class="span-10 notice clear">
					This client has set a high flag and needs urgent attention.
		</div><br />
		';
	}
	?>
	<div class="span-18">
		<div class="span-9">
			<form id="updateclient" method="post" name="updateclient" action="../inc/process-update.php">
			<fieldset>
				<legend>Update Information</legend>
				<label for="hours">How long did the update take? (minutes)</label><br/ >
				<input type="text" name="minutes" id="minutes" class="text-hours" /><br />
				<label for="completed">Is this update completed?</label><br/ >
				<input type="checkbox" name="completed" id="completed" /><br />
				<label for="who">Who is working on this update?</label><br/ >
				<select name="who" id="who">
					<option value="0">Choose One</option>
					<?php
						$sql    = "SELECT a_id,lname FROM admin";
						$query  = mysql_query($sql) or die(mysql_error());
						while($row = mysql_fetch_array($query)){
							print '<option value="'.$row["a_id"].'">'.$row["lname"].'</option>';
						}
					?>
				</select>
			</fieldset>
			<input type="hidden" name="u_id" id="u_id" value="<?php echo $u_id; ?>" />
			<input type="hidden" name="p_id" id="p_id" value="<?php echo $p_id; ?>"/>
			</form>
		</p>
			<br />
		</div>
		<div class="span-9">
			<div class="success" style="display:none;">Data has been updated.</div>
		</div>
	</div>

